/**
 * Created with IntelliJ IDEA.
 * Description:代码块
 * User: 86183
 */
class Student1{
    //成员变量
    public String name;
    public String gender;
    public int age;
    public static String className ;
    public static String teacherName;
    public Student1() {
        System.out.println("调用了无参构造方法");
    }
    {
        System.out.println("调用了构造代码块1/实例代码块1");
    }
    {
        System.out.println("调用了构造代码块2/实例代码块2");
    }
    static {
        teacherName = "小贺";//给静态成员变量初始化
        System.out.println("调用了teacherName静态代码块");
    }

    static {
        className = "1班";//给静态成员变量初始化
        System.out.println("调用了className静态代码块");
    }

    public Student1(String name, String gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        System.out.println("调用了有参构造方法");
    }

}
public class Test6 {
    public static void main(String[] args) {
        Student1 student1 = new Student1();
        System.out.println("===========");
        Student1 student2 = new Student1();
        System.out.println("===========");
        Student1 student3 = new Student1();
       /* //普通代码块
        {
            int x = 10;
            System.out.println(x);
        }*/
    }
}
